package com.CloudDream.Command.Player;

import com.CloudDream.Gui.gui.CookGui;
import com.CloudDream.MoonCake;
import com.handy.lib.command.IHandyCommandEvent;
import com.handy.lib.util.BaseUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;

public class CTCommand implements IHandyCommandEvent {

    @Override
    public String command() {
        return "table";
    }

    @Override
    public String permission() {
        return "mooncake.table";
    }

    public void onCommand(final CommandSender commandSender, Command command, String s, String[] strings) {
        if(BaseUtil.isNotPlayer(commandSender).booleanValue()){
            commandSender.sendMessage(MoonCake.prefix + "§7该命令只能由玩家执行");
            return;
        }
        final Player p = (Player) commandSender;
        (new BukkitRunnable(){
            public void run() {
                p.closeInventory();
                p.openInventory(CookGui.open(p));
            }
        }).runTaskAsynchronously(MoonCake.getInstance());
    }
}
